<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>头条热榜</title>
    <style>
        *{
            margin:0;
            padding:0;
            box-sizing: border-box;
            list-style: none;
        }
        .container{
            padding: 20px;
            margin: 50px;
        }
        h2{
            padding-bottom: 20px;
        }
        .order{
            margin-right: 15px;
            font-weight: bold;
        }
        .title{
            margin-right: 15px;
        }
        .hot{
            font-size: 10px;
            padding: 2px 4px;
            background: rgb(134, 10, 10);
            color:white;
            border-radius: 3px;
        }
        .new{
            font-size: 10px;
            padding: 2px 4px;
            background: rgb(182, 148, 38);
            color:white;
            border-radius: 3px;
        }
        li{
            margin-bottom: 20px;
        }
        .num-1{
            color: rgb(171, 54, 54);
        }
        .num-2{
            color: rgb(241, 76, 77);
        }
        .num-3{
            color: rgb(255, 159, 16);
        }
    </style>
</head>

<body>
    <div id="root">
        
    </div>

    <script src="./js/react.development.js"></script>
    <script src="./js/react-dom.development.js"></script>
    <script src="./js/babel.min.js"></script>
    <script type="text/babel">
        // https://www.toutiao.com/
        let data = [
            { id: 1, title: '河北通勤车坠河瞬间曝光', is_hot: true, is_new: false },
            { id: 2, title: '国足公布对阵沙特23人大名单', is_hot: true, is_new: false },
            { id: 3, title: '“争控”成中印边境谈判关键词', is_hot: true, is_new: false },
            { id: 4, title: '五粮液独董郎定常因突发疾病去世', is_hot: false, is_new: false },
            { id: 5, title: '王立科被逮捕：曾想停播人民的名义', is_hot: false, is_new: true },
            { id: 6, title: '台风“圆规”路径', is_hot: true, is_new: false },
            { id: 7, title: '保姆报复前雇主偷走其最爱煎锅', is_hot: true, is_new: false },
            { id: 8, title: '中国南海军事演习引发海外关注', is_hot: false, is_new: false },
            { id: 9, title: '河北坠河班车已致14人遇难', is_hot: true, is_new: false },
        ];

        class App extends React.Component {
            render(){
                return <div className="container">
                    <h2>头条热榜</h2>
                    <ul>
                        {
                            data.map((item, index) => {
                                return <li key={index}>
                                    <span className={"order num-"+(index+1)}>{item.id}</span>
                                    <span className="title">{item.title}</span>
                                    {item.is_hot && <span className="hot">热</span>}
                                    {item.is_new && <span className="new">新</span>}
                                </li>
                            })
                        }
                    </ul>
                </div>
            }
        }

        ReactDOM.render(<App />, document.querySelector("#root"));

        
    </script>
</body>

</html>